package taskinstance;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TimingTask extends Task{ 
  private String startTime;
  
  public TimingTask(String sourceIp, String targetIp,
      String fileName, String startTime) {
    super(sourceIp, targetIp, fileName);
    this.startTime = startTime;
  }
  
  public long getDelayTime() {
    DateFormat sdf = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
    try {
      Date date = sdf.parse(startTime);
      Date now = new Date();
     
      return date.getTime() - now.getTime();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return 0;
  }
  
  @Override
  public String toString() {
    return "" + targetIp + "\t" + fileName + "\t" + "(Start at: " + startTime + ")";
  }

}
